home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / lists / mint / l_0799 / 732 < prev    next >
Encoding:
Internet Message Format  |  1994-08-27  |  2.5 KB

  1. From: Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
  2. Date: Wed, 29 Dec 93 10:59:20 +0100
  3. Message-Id: <9312290959.AA16598@issan.informatik.uni-dortmund.de>
  4. To: mint@atari.archive.umich.edu
  5. Subject: MiNT 1.09: allow Dfree on any drive
  6.  
  7. Currently, Dfree only works if the drive is a root, a current
  8. directory or an alias, or one of the standard drives.  This patch
  9. extends it to work for any drive.  It adds a new function to unifs.c
  10. to return the filesystem structure for a given drive number, that can
  11. then be used to get a cookie for the root directory.  Currently, all
  12. of the special filesystems like /proc ignore the cookie in the dfree
  13. call, but others could use it to distinguish between different drives.
  14.  
  15. --- orig/dosdir.c    Mon Aug  2 18:57:34 1993
  16. +++ dosdir.c    Mon Dec 27 17:22:34 1993
  17. @@ -43,6 +43,9 @@
  18.      int d;
  19.  {
  20.      fcookie *dir = 0;
  21. +    FILESYS *fs;
  22. +    fcookie root;
  23. +    long r;
  24.      extern int aliasdrv[];
  25.  
  26.      TRACE(("Dfree(%d)", d));
  27. @@ -53,12 +56,9 @@
  28.      else
  29.          d = curproc->curdrv;
  30.  
  31. -/* Hack to make programs (like df) which use drive
  32. - * information from Fxattr() work more often.
  33. - * BUG: this works only if the drive is a root,
  34. - * a current directory or an alias, or one of the
  35. - * standard drives.
  36. - */
  37. +/* If it's not a standard drive or an alias of one, get the pointer to
  38. +   the filesystem structure and use the root directory of the
  39. +   drive. */
  40.      if (d < 0 || d >= NUM_DRIVES) {
  41.          int i;
  42.  
  43. @@ -67,16 +67,17 @@
  44.                  d = i;
  45.                  goto aliased;
  46.              }
  47. -            if (curproc->curdir[i].dev == d) {
  48. -                dir = &curproc->curdir[i];
  49. -            } else if (curproc->root[i].dev == d) {
  50. -                dir = &curproc->root[i];
  51. -            }
  52. -        }
  53. -        if (dir && dir->fs) {
  54. -            return (*dir->fs->dfree)(dir, buf);
  55.          }
  56. -        return EDRIVE;
  57. +
  58. +        fs = get_filesys (d);
  59. +        if (!fs)
  60. +          return EDRIVE;
  61. +        r = fs->root (d, &root);
  62. +        if (r < 0)
  63. +          return r;
  64. +        r = (*fs->dfree) (&root, buf);
  65. +        release_cookie (&root);
  66. +        return r;
  67.      }
  68.  
  69.  /* check for a media change -- we don't care much either way, but it
  70. --- orig/proto.h    Tue Jul 27 22:31:54 1993
  71. +++ proto.h    Thu Dec  9 23:28:58 1993
  72. @@ -338,6 +338,7 @@
  73.  /* tosfs.c */
  74.  
  75.  /* unifs.c */
  76. +FILESYS *get_filesys P_((int));
  77.  void unifs_init P_((void));
  78.  
  79.  /* debug.c */
  80. --- orig/unifs.c    Tue Jul 27 22:05:06 1993
  81. +++ unifs.c    Sat Dec 25 22:25:26 1993
  82. @@ -68,6 +68,18 @@
  83.  static UNIFILE u_drvs[UNI_NUM_DRVS];
  84.  static UNIFILE *u_root = 0;
  85.  
  86. +FILESYS *
  87. +get_filesys (dev)
  88. +     int dev;
  89. +{
  90. +  UNIFILE *u;
  91. +
  92. +  for (u = u_root; u; u = u->next)
  93. +    if (u->dev == dev)
  94. +      return u->fs;
  95. +  return (FILESYS *) 0L;
  96. +}
  97. +
  98.  void
  99.  unifs_init()
  100.  {
  101.